const Router = require('koa-router')
const {
  HotCommentsController,
  SearchController,
  TopListController,
  UserController,
  TaskController,
  PushController
} = require('./controllers')

const apiRouter = new Router({ prefix: '/api' })

exports.api = apiRouter
  .get('/ping', ctx => {
    ctx.response.body = 'pong'
  })
  .get('/comment/:id', HotCommentsController.getList)
  .get('/search', SearchController.search)
  .get('/top/list', TopListController.getList)
  .post('/user/login', UserController.login)
  .get('/user/register', UserController.register)
  .post('/task', TaskController.createTask)
  .get('/task/list', TaskController.getTaskList)
  .delete('/task/:id', TaskController.deleteTask)
  .put('/task/:id', TaskController.updateTask)
  .get('/push/:id', PushController.push)
